package filter

import (
	"github.com/beego/beego/v2/server/web/context"
	"rate/common/consts"
	"rate/common/res"
	"rate/common/util/cache"
)

// LoginFilter 登录验证
var LoginFilter = func(ctx *context.Context) {
	token := ctx.Input.Header("token")
	member := cache.GetToken(token)
	if member == nil {
		res.CtxFail(ctx, consts.UnLogin)
	} else {
		// 存放用户信息
		ctx.Input.SetData("member", member)
	}

}
